package com.example.pc.adapterdemo.base;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

import com.example.pc.adapterdemo.R;
import com.yanzhenjie.sofia.Sofia;

import java.util.Objects;

public class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    //设置全屏方法
    public void setFullscreen(boolean tags){
        if (tags){
            //全屏 去除状态栏
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.activity_main);//要放到加载布局文件代码之前
        }
    }

    //设置沉浸式状态栏
    public void getContent(Activity activity){
        //状态栏与标题栏阴影
        Objects.requireNonNull(getSupportActionBar()).setElevation(0);
        Sofia.with(activity)
                .statusBarLightFont()
                .statusBarBackground(getResources().getColor(R.color.colorPrimary))
                .navigationBarBackground(getResources().getColor(R.color.colorPrimary));
    }
}
